package com.aaa.ssm.result;

import lombok.Data;

import java.io.Serializable;

@Data
public class AjaxResult implements Serializable {
    private int code; // 返回码，如200表示成功
    private String  msg; // 返回信息
    private Object data;



    public static AjaxResult success(){
        return new AjaxResult(200,"成功",null);
    }
    public static AjaxResult success(Object data){
        return new AjaxResult(200,"成功", data);
    }
    public static AjaxResult error(){
        return new AjaxResult(400,"失败", null);
    }
    public static AjaxResult error(String msg){
        return new AjaxResult(400,msg, null);
    }
    public static AjaxResult error(int code, Object data){
        return new AjaxResult(code,null, data);
    }


    public AjaxResult() {}

    public AjaxResult(int code, String msg, Object data) {
        this.code = code;
        this.msg= msg;
        this.data = data;


    }



    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return msg;
    }

    public void setMessage(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
